#include "include.h"
#include "func.h"
#include "func_music.h"
#include "func_exspiflash_music.h"

#if (EX_SPIFLASH_SUPPORT)
extern void func_lower_power_check(void);
u8 music_key_hold_cnt=0;
AT(.text.func.music.msg)
void func_exspifalsh_music_message(u16 msg)
{

   if(msg!=0&&msg!=0x7ff&&(msg&0x800))
	{
		printf("msg:0x%x\n",msg);
	}
    switch (msg) {
        case K_SONG1:
			music_key_hold_cnt=0;
			func_switch_song(0);
            break;
        case K_SONG2:
			music_key_hold_cnt=0;
			func_switch_song(1);
			break;
		case KU_BT:
			music_key_hold_cnt=0;
			music_control(MUSIC_MSG_STOP);
			func_cb.sta = FUNC_BT;
			break;
		case KL_BT:
			music_key_hold_cnt=0;
			music_control(MUSIC_MSG_STOP);
			sys_cb.bt_mode=1;			
			func_cb.sta =FUNC_BT;
			break;
		case KLU_EQ:
		music_key_hold_cnt=0;
		break;
		case KH_EQ:
		music_key_hold_cnt++;
		printf("hold cnt:%d\n",music_key_hold_cnt);
		if(music_key_hold_cnt==10)
		{
			func_music_QRcode_disable();
		}		
		break;
        case KL_POWER:
		case KU_POWER:
			music_control(MUSIC_MSG_STOP);
			sys_cb.pwrdwn_tone_en = 1;
			func_cb.sta =FUNC_PWROFF;
			break;
		case MSG_SYS_1S:
			func_lower_power_check();
			func_check_timeout();
			
			
			break;
		case EVT_MIC_INSERT:
			printf("mic_unmute\n");
			func_switch_mic_onoff(1);
			break;
		case EVT_MIC_REMOVE:
			printf("mic_mute\n");
			func_switch_mic_onoff(0);
			break;
		case EVT_MODE_3P_TO_DEMO:
		case EVT_MODE_3P_TO_HOME:
			printf("3p switch!!\n");
			music_control(MUSIC_MSG_STOP);
			sys_cb.pwrdwn_tone_en = 0;
			func_cb.sta =FUNC_PWROFF;
			break;
        default:
			//auto_stop_play_timer();
           // non_volatile_memory();
            func_message(msg);
            break;
    }
}
#endif //(EX_SPIFLASH_SUPPORT & EXSPI_MUSIC)

